package com.psp.bu.persist.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.psp.bu.model.CategoryProductRelationBean;
import com.psp.bu.model.ProductAttributeBean;
import com.psp.bu.model.ProductAttributeRelationBean;
import com.psp.bu.model.ProductSkuBean;
import com.psp.bu.persist.dao.ProductAttributeDao;

@Repository
public class ProductAttributeImpl extends BaseImpl implements ProductAttributeDao {
	
	final String NAME_SPACE = NAME_SPACE_HEADER + ".ProductAttributeMapper";

	@Override
	public int updateList(List<ProductAttributeBean> attrs) {
		return sqlSessionTemplate.update(NAME_SPACE + ".updateList", attrs);
	}

	@Override
	public int insertList(List<ProductAttributeBean> attrs) {
		return sqlSessionTemplate.insert(NAME_SPACE + ".insertList", attrs);
	}

	@Override
	public List<ProductAttributeBean> selectListByPid(String pid) {
		return sqlSessionTemplate.selectList(NAME_SPACE + ".selectListByPid", pid);
	}

	@Override
	public List<ProductAttributeBean> selectListByCateCode(int cateCode) {
		return sqlSessionTemplate.selectList(NAME_SPACE + ".selectListByCateCode", cateCode);
	}

	@Override
	public int insertProAttriRelation(List<ProductAttributeRelationBean> relas) {
		return sqlSessionTemplate.insert(NAME_SPACE + ".insertProAttriRelation", relas);
	}
	
	@Override
	public int insertCateProductRelation(CategoryProductRelationBean cate) {
		return sqlSessionTemplate.insert(NAME_SPACE + ".insertCateProductRelation", cate);
	}
	
	@Override
	public int insertProductUpdateLog(ProductAttributeRelationBean log) {
		return sqlSessionTemplate.insert(NAME_SPACE + ".insertProductUpdateLog", log);
	}

	@Override
	public int insertProductSkuList(List<ProductSkuBean> skus) {
		return sqlSessionTemplate.insert(NAME_SPACE + ".insertProductSkuList", skus);
	}
	
	@Override
	public int updateProAttributes(String pid, int i) {
		Map<String, Object> where = new HashMap<>();
		where.put("pid", pid);
		where.put("state", i);
		return sqlSessionTemplate.update(NAME_SPACE + ".updateProAttributes", where);
	}

	@Override
	public int updateProSkus(String pid, int i) {
		Map<String, Object> where = new HashMap<>();
		where.put("pid", pid);
		where.put("state", i);
		return sqlSessionTemplate.update(NAME_SPACE + ".updateProSkus", where);
	}



}
